package com.qigao.mall.web.controller;

import com.qigao.mall.api.OrderService;
import com.qigao.mall.commons.dto.OrderResultDto;
import com.qigao.mall.commons.enums.Result;
import com.qigao.mall.commons.enums.ResultCode;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;

@Component
public class AbstractOrderController extends AbstractExcelController {
    private static Logger logger= LoggerFactory.getLogger(AbstractOrderController.class);
    @Resource
    OrderService orderService;

    //3.按照订单号查询订单信息
    @GetMapping("/findOrderByNo/{orderNo}")
    @ApiOperation(value = "按照订单号查询订单信息", notes = "按照订单号查询订单信息")
    public Result<OrderResultDto> findOrderByNo(@PathVariable("orderNo")String orderNo){
        try{
            //参数校验
            return orderService.findOrderByNo(orderNo);
        }catch (Exception e){
            logger.error("[订单查询列表]发生异常:{}",e);
            return Result.newError(ResultCode.FAIL);
        }
    }

}
